package com.trinh.utils.crypto.enu;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * @Author: TrinhRae
 * @Package: com.trinh.utils.crypto.enu
 * @Project: generaltools
 * @Date: 2025/6/20 14:40
 */
public enum CharFormater {

    UTF_8(new Utf8Tool()),
    BASE64(new Base64Tool());

    private final TransTool transTool;

    CharFormater(TransTool transTool) {
        this.transTool = transTool;
    }

    public TransTool getTool() {
        return transTool;
    }

    public interface TransTool {
        byte[] toBytes(String input);
    }

    public static class Utf8Tool implements TransTool {
        @Override
        public byte[] toBytes(String input) {
            return input.getBytes(StandardCharsets.UTF_8);
        }
    }

    public static class Base64Tool implements TransTool {
        @Override
        public byte[] toBytes(String input) {
            return Base64.getDecoder().decode(input);
        }
    }
}

